import 'dart:io';
import 'package:word_game/altar.dart';
import 'package:word_game/engine/core.dart';
import 'package:word_game/gate.dart';
import 'package:yaml/yaml.dart';

class SceneManager extends Object {
  static SceneManager instance = SceneManager();

  Map<String, Scene> _objectMap={};

  appendObjectsFromYAML(String fileName) {
    var content = File(fileName).readAsStringSync();
    var yaml = loadYaml(content);
    var items = yaml['scenes'] as List;
    for (var item in items) {
      Scene obj;
      var type = item['type'];
      if (type=='Altar') {
        obj = Altar(item);
      } else if (type=='Gate') {
        obj = Gate(item);
      } else {
        obj = Scene(item);
      }
      
      _objectMap[obj.code] = obj;
    }
  }

  Scene objectWithCode(String code) {
    return _objectMap[code];
  }

}